package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Disease;
import com.g8.pethospitallearnbackend.entity.DiseaseExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface DiseaseMapper {
    @SelectProvider(type=DiseaseSqlProvider.class, method="countByExample")
    long countByExample(DiseaseExample example);

    @DeleteProvider(type=DiseaseSqlProvider.class, method="deleteByExample")
    int deleteByExample(DiseaseExample example);

    @Delete({
        "delete from disease",
        "where disease_id = #{diseaseId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String diseaseId);

    @Insert({
        "insert into disease (disease_id, type_id, ",
        "disease_name, disease_desc, ",
        "disease_treat, disease_pic, ",
        "disease_video)",
        "values (#{diseaseId,jdbcType=VARCHAR}, #{typeId,jdbcType=VARCHAR}, ",
        "#{diseaseName,jdbcType=VARCHAR}, #{diseaseDesc,jdbcType=LONGVARCHAR}, ",
        "#{diseaseTreat,jdbcType=LONGVARCHAR}, #{diseasePic,jdbcType=LONGVARCHAR}, ",
        "#{diseaseVideo,jdbcType=LONGVARCHAR})"
    })
    int insert(Disease record);

    @InsertProvider(type=DiseaseSqlProvider.class, method="insertSelective")
    int insertSelective(Disease record);

    @SelectProvider(type=DiseaseSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="disease_id", property="diseaseId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease_name", property="diseaseName", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease_desc", property="diseaseDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_treat", property="diseaseTreat", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_pic", property="diseasePic", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_video", property="diseaseVideo", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Disease> selectByExampleWithBLOBs(DiseaseExample example);

    @SelectProvider(type=DiseaseSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="disease_id", property="diseaseId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease_name", property="diseaseName", jdbcType=JdbcType.VARCHAR)
    })
    List<Disease> selectByExample(DiseaseExample example);

    @Select({
        "select",
        "disease_id, type_id, disease_name, disease_desc, disease_treat, disease_pic, ",
        "disease_video",
        "from disease",
        "where disease_id = #{diseaseId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="disease_id", property="diseaseId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease_name", property="diseaseName", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease_desc", property="diseaseDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_treat", property="diseaseTreat", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_pic", property="diseasePic", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="disease_video", property="diseaseVideo", jdbcType=JdbcType.LONGVARCHAR)
    })
    Disease selectByPrimaryKey(String diseaseId);

    @UpdateProvider(type=DiseaseSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Disease record, @Param("example") DiseaseExample example);

    @UpdateProvider(type=DiseaseSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Disease record, @Param("example") DiseaseExample example);

    @UpdateProvider(type=DiseaseSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Disease record, @Param("example") DiseaseExample example);

    @UpdateProvider(type=DiseaseSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Disease record);

    @Update({
        "update disease",
        "set type_id = #{typeId,jdbcType=VARCHAR},",
          "disease_name = #{diseaseName,jdbcType=VARCHAR},",
          "disease_desc = #{diseaseDesc,jdbcType=LONGVARCHAR},",
          "disease_treat = #{diseaseTreat,jdbcType=LONGVARCHAR},",
          "disease_pic = #{diseasePic,jdbcType=LONGVARCHAR},",
          "disease_video = #{diseaseVideo,jdbcType=LONGVARCHAR}",
        "where disease_id = #{diseaseId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Disease record);

    @Update({
        "update disease",
        "set type_id = #{typeId,jdbcType=VARCHAR},",
          "disease_name = #{diseaseName,jdbcType=VARCHAR}",
        "where disease_id = #{diseaseId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Disease record);

    @Select("select * from disease where type_id=#{typeId};")
    List<Disease> selectDiseasesByTypeId(@Param("typeId") String typeId);
    @Select("select disease_id from disease where disease_name=#{diseaseName};")
    String selectDiseaseIdByName(@Param("diseaseName") String diseaseName);

    @Select("select * from disease where disease_id=#{diseaseId}")
    Disease selectADiseaseById(@Param("diseaseId") String diseaseId);

    @Select("select disease_id, disease_name from disease")
    List<Disease> selectAllIdAndName();
}